home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
FNTPAK32.ZIP
/
C.EXE
/
DEMO_GMS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-16
|
5KB
|
157 lines
/**********************************************************************
Demo_GMX.C Copyright 1994, Rob W. Smetana
Turn Screen Swapping ON if appropriate.
Demonstrate how to:
1. Select GRAPHICS-mode mouse cursor shapes from Font Pak's library.
2. Determine how many mouse shapes there are.
Requires:
a. Graphics.Lib
1. Mouse.Obj (which contains mouse functions)
2. LdGFXCsr.OBJ (graphics-mode mouse shapes)
Notes:
It is CRITICAL that you be in GRAPHICS-mode when you call the
graphics-mode procedures. A crash awaits you if you're not.
*************************************************************************\
/* #include <dos.h> */
#include <graph.h>
#include <font_pak.h>
/* We'll demonstrate these. Prototypes are in Font_Pak.H.
void extern pascal far RSLOADGFXCURSOR (int, int, int);
int extern pascal far NUMGFXSHAPES ();
*/
/* GetMonitor function is in video.obj */
extern int GetMonitor ();
int FontSize (); /* local get-monitor function to detect EGA/VGA
and return size of default font (14/16)
-or- print error message if appropriate
*/
int main (void)
{
int FSize, WhichShape, HotSpotX, HotSpotY, Button, Row, Col, GFXorText;
int NumShapes;
NumShapes = NUMGFXSHAPES (); /* how many graphics-mode cursors are there?*/
_setvideomode(_TEXTC80);
FSize = FontSize (); /* FontSize returns 14, 16 or 0 (no EGA/VGA) */
if (FSize == 0) /* Bail out if no EGA/VGA */
return (-99);
FSize = RSTHEREISAMOUSE;
if (FSize == 0) /* Bail out if there's no mouse */
{
printf ("Sorry. This demo requires a mouse/mouse driver. I found none.");
getch();
return (-99);
}
_setvideomode(_ERESCOLOR); /* BE SURE you're in graphics mode
BEFORE calling gfx-mode functions!
*/
printf(" Demonstrate how to select one of %d GRAPHICS-mode mouse cursor shapes.\n\n",NumShapes);
printf("Here's the normal (default) mouse shape. Click a mouse button to try a new one.");
GFXorText = -1; /* -1 = return graphics mode row/col */
RSSHOWCURSOR ();
for (WhichShape = 0; WhichShape < NumShapes+1; WhichShape++)
{
/* scrub any remaining button clicks */
while (Button > 0)
Button = RSBUTTONPRESSED (&Row, &Col, GFXorText);
/* now wait for a button click */
Button = 0;
while (Button == 0)
Button = RSBUTTONPRESSED (&Row, &Col, GFXorText);
/* load the next cursor shape */
RSHIDECURSOR ();
RSLOADGFXCURSOR (WhichShape + 1, HotSpotX, HotSpotY);
RSSHOWCURSOR ();
/* gotoxy (30,4); write('This is cursor # ', WhichShape); */
}
/* restore default by loading shape #16 */
RSLOADGFXCURSOR (16, HotSpotX, HotSpotY);
FSize = RSTHEREISAMOUSE;
_setvideomode(_DEFAULTMODE);
printf ("That's all . . .");
return (0);
} /* end main */
/*******************************************************************
Function: FontSize
Purpose: Check for EGA/VGA and return 14 (EGA 8x14), 16 (VGA 8x16)
or 0 if we're not using an EGA/VGA
Print error message and end if no EGA/VGA
GetMonitor returns an integer (0 - 8) indicating the type of monitor
in use. If two monitors are being used, GetMonitor returns
the type of the primary monitor.
0 = None (no monitor) 3 = EGA (or MultiSync)
4 = Color (CGA) 5 = Monochrome
7 = VGA Monochrome 8 = VGA Color (or MultiSync)
*******************************************************************/
int FontSize ()
{
int MonType;
MonType = GETMONITOR();
switch (MonType) {
case 0, 4, 5: /* no monitor, Mono or CGA */
printf ("Sorry. An EGA or VGA monitor is required to run this demo. \n\n");
return (0);
break;
case 3: /* EGA. Set fontsize to 8x14 */
return (14);
break;
case 7, 8: /* VGA. Set fontsize to 8x16 */
return (16);
break;
default:
printf ("Unknown monitor type. Sorry. An EGA or VGA monitor is required to run this. \n\n");
return (0);
break;
}
}